home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr49 / vesa18.zip / VESA_S3.C < prev    next >
C/C++ Source or Header  |  1995-01-28  |  5KB  |  133 lines

  1. /* VESA package for emx/gcc --- Copyright (c) 1993 by Johannes Martin */
  2. #include <string.h>
  3. #include <sys/hw.h>
  4.  
  5. #define INCL_VIO
  6. #define INCL_DOSPROCESS
  7.  
  8. #include <os2emx.h>
  9. #include <os2thunk.h>
  10.  
  11. #include "vgaports.h"
  12. #include "vesa.h"
  13. #include "vesadll.h"
  14. #include "common.h"
  15.  
  16. static VESAWORD _Modes[] = { 0x003, 0x012, 0x013, 0x101, 0x102, 0x103,
  17.                              0x104, 0x105, 0x106, 0x107, 0x111, 0x112,
  18.                              0x114, 0x115, 0x117, 0xFFFF };
  19.  
  20. static struct _ModeInfo _ModeInfos[] =
  21.     { { 0x1, { 0x0f, 0x7, 0x0, 64, 64, 0x0, 0x0,
  22.                OS2VesaSetWindow, OS2VesaGetWindow, 160,
  23.                640, 400, 8, 16, 1, 4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  24.       { 0x3, { 0x1b, 0x7, 0x0, 16, 64, 0x0, 0x0,
  25.                OS2VesaSetWindow, OS2VesaGetWindow, 80,
  26.                640, 480, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  27.       { 0x3, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  28.                OS2VesaSetWindow, OS2VesaGetWindow, 320,
  29.                320, 200, 8,  8, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  30.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  31.                OS2VesaSetWindow, OS2VesaGetWindow, 640,
  32.                640, 480, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  33.       { 0xb, { 0x1b, 0x7, 0x0, 16, 64, 0x0, 0x0,
  34.                OS2VesaSetWindow, OS2VesaGetWindow, 100,
  35.                800, 600, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  36.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  37.                OS2VesaSetWindow, OS2VesaGetWindow, 800,
  38.                800, 600, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  39.       { 0xb, { 0x1b, 0x7, 0x0, 16, 64, 0x0, 0x0,
  40.                OS2VesaSetWindow, OS2VesaGetWindow, 128,
  41.                1024, 768, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  42.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  43.                OS2VesaSetWindow, OS2VesaGetWindow, 1024,
  44.                1024, 768, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  45.       { 0xb, { 0x1b, 0x7, 0x0, 16, 64, 0x0, 0x0,
  46.                OS2VesaSetWindow, OS2VesaGetWindow, 160,
  47.                1280, 1024, 8, 16, 4, 4, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  48.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  49.                OS2VesaSetWindow, OS2VesaGetWindow, 1280,
  50.                1280, 1024, 8, 16, 1, 8, 1, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 } },
  51.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  52.                OS2VesaSetWindow, OS2VesaGetWindow, 1280,
  53.                640, 480, 8, 16, 1, 16, 1, 6, 0, 1, 5, 11, 6, 5, 5, 0, 0, 0 } },
  54.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  55.                OS2VesaSetWindow, OS2VesaGetWindow, 2048,
  56.                640, 480, 8, 16, 1, 24, 1, 6, 0, 1, 8, 16, 8, 8, 8, 0, 0, 0 } },
  57.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  58.                OS2VesaSetWindow, OS2VesaGetWindow, 1600,
  59.                800, 600, 8, 16, 1, 16, 1, 6, 0, 1, 5, 11, 6, 5, 5, 0, 0, 0 } },
  60.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  61.                OS2VesaSetWindow, OS2VesaGetWindow, 2400,
  62.                800, 600, 8, 16, 1, 24, 1, 6, 0, 1, 8, 16, 8, 8, 8, 0, 0, 0 } },
  63.       { 0xb, { 0x1b, 0x7, 0x0, 64, 64, 0x0, 0x0,
  64.                OS2VesaSetWindow, OS2VesaGetWindow, 2048,
  65.                1024, 768, 8, 16, 1, 16, 1, 6, 0, 1, 5, 11, 6, 5, 5, 0, 0, 0 } }
  66.     };
  67.  
  68. VESAWORD *Modes             = _Modes;
  69. struct _ModeInfo *ModeInfos = _ModeInfos;
  70.  
  71. VESABOOL Initialize(void)
  72. {
  73.   _portaccess(CRT_I, CRT_D);
  74.   return(TRUE);
  75. }
  76.  
  77. VOID ClearUp(void)
  78. {
  79. }
  80.  
  81. VOID *GetPhysBuf(void)
  82. {
  83.   VIOMODEINFO ModeInfo;
  84.   VIOPHYSBUF  PhysBuf;
  85.  
  86.   ModeInfo.cb  = sizeof(ModeInfo);
  87.   VioGetMode(&ModeInfo, 0);
  88.   PhysBuf.pBuf = (PBYTE) ModeInfo.buf_addr;
  89.   PhysBuf.cb   = 0x10000;
  90.   if (VioGetPhysBuf(&PhysBuf, 0) != 0)
  91.     return(NULL);
  92.   else
  93.     return(MAKEP(PhysBuf.asel[0], 0));
  94. }
  95.  
  96. VESABOOL SetMode(VESAWORD mode)
  97. {
  98.   VIOMODEINFO ModeInfo;
  99.  
  100.   if (mode != 3)
  101.     SetMode(3);
  102.   ModeInfo.cb     = 12;
  103.   ModeInfo.fbType = ModeInfos[mode].fbtype;
  104.   ModeInfo.color  = ModeInfos[mode].Vesa.NumberOfBitsPerPixel;
  105.   ModeInfo.col    = ModeInfos[mode].Vesa.Width  / ModeInfos[mode].Vesa.CharacterWidth;
  106.   ModeInfo.row    = ModeInfos[mode].Vesa.Height / ModeInfos[mode].Vesa.CharacterHeight;
  107.   ModeInfo.hres   = ModeInfos[mode].Vesa.Width;
  108.   ModeInfo.vres   = ModeInfos[mode].Vesa.Height;
  109.   return(VioSetMode(&ModeInfo, 0) == 0);
  110. }
  111.  
  112. void SetSpecial(VESAWORD mode)
  113. {
  114. }
  115.  
  116. VESABOOL OS2VesaSetWindow(VESACHAR Window, VESAWORD Address)
  117. {
  118. /* the following lines are possibly not necessary   */
  119. /*  _outp8(CRT_I, 0x31);                            */
  120. /*  _outp8(CRT_D, _inp8(CRT_D) | 9);                */
  121. /* the following lines have to be there             */
  122.   _outp8(CRT_I, 0x35);
  123.   _outp8(CRT_D, Address);
  124.   return(TRUE);
  125. }
  126.  
  127. VESABOOL OS2VesaGetWindow(VESACHAR Window, PVESAWORD Address)
  128. {
  129.   _outp8(CRT_I, 0x35);
  130.   *Address = _inp8(CRT_D) & 0x0F;
  131.   return(TRUE);
  132. }
  133.